package com.signway.interfacejump.slice;

import com.signway.interfacejump.ResourceTable;
import com.signway.interfacejump.utils.CommonData;
import com.signway.interfacejump.utils.LogUtil;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Text;
import ohos.agp.utils.LayoutAlignment;
import ohos.agp.window.dialog.ToastDialog;

public class MainAbilitySlice extends AbilitySlice {
    public static final String TAG = CommonData.TAG + MainAbilitySlice.class.getSimpleName();

    public MainAbilitySlice() {
        LogUtil.info(TAG, "new");
    }

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_main);
        LogUtil.info(TAG, "onStart");

        Text text = (Text) findComponentById(ResourceTable.Id_text_main);
        text.setClickedListener(commend -> {
            present(new SecondAbilitySlice(), new Intent());
        });

        Text dialog = (Text) findComponentById(ResourceTable.Id_text_dialog);
        dialog.setClickedListener(commend -> {
            new ToastDialog(getContext()).setText("回答正确").setAlignment(LayoutAlignment.CENTER).show();
        });
    }

    @Override
    protected void onForeground(Intent intent) {
        super.onForeground(intent);
        LogUtil.info(TAG, "onForeground");
    }

    @Override
    protected void onActive() {
        super.onActive();
        LogUtil.info(TAG, "onActive");
    }

    @Override
    protected void onInactive() {
        super.onInactive();
        LogUtil.info(TAG, "onInactive");
    }

    @Override
    protected void onBackground() {
        super.onBackground();
        LogUtil.info(TAG, "onBackground");
    }

    @Override
    protected void onStop() {
        super.onStop();
        LogUtil.info(TAG, "onStop");
    }
}
